package springinpractice.ch3.web;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import springinpractice.ch3.model.Member;

/*
 * Author	:	Willie Wheeler and John Wheeler
 * Book		:	'Spring In Practice' [Book written by Willie Wheeler and John Wheeler]
 */

@Controller
public final class RosterController {
	private List<Member> members = new ArrayList<Member>();
	
	public RosterController() {
		members.add(new Member("John", "Lennon",1));
		members.add(new Member("Paul", "McCartney",2));
		members.add(new Member("George", "Harrison",3));
		members.add(new Member("Ringo", "Starr",4));
	}
	
	@RequestMapping("roster/list.htm")
	public void list(Model model) {
		model.addAttribute(members);
	}
	
	@RequestMapping("roster/member.htm")
	public void member(@RequestParam("id") Integer id, Model model) {
		model.addAttribute(members.get(id));
	}
}
